package com.cs.peanut.base_app.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

import com.cs.peanut.base_app.TCPUitls;

import java.io.IOException;

public class MyService extends Service {
    AndroidWebServer androidWebServer;
    public MyService() {
    }

    @Override
    public void onCreate() {
        super.onCreate();
        androidWebServer = new AndroidWebServer(8080);
        try {
            androidWebServer.start();
            androidWebServer.addServlet(new ServletImpl(this));
            Log.e("ip:", "" + TCPUitls.int2Ip(TCPUitls.getIpAddress(this)) + ":" + 8080);
        } catch (IOException e) {
            e.printStackTrace();
            //尝试杀死端口，然后重启服务
        }
    }

    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
        throw new UnsupportedOperationException("Not yet implemented");
    }
}
